package cn.kgc.mes.storage.service.impl;

import java.util.List;
import cn.kgc.mes.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.kgc.mes.storage.mapper.StorageAreaMapper;
import cn.kgc.mes.storage.domain.StorageArea;
import cn.kgc.mes.storage.service.IStorageAreaService;

/**
 * 库位设置Service业务层处理
 * 
 * @author ydw
 * @date 2025-09-12
 */
@Service
public class StorageAreaServiceImpl implements IStorageAreaService 
{
    @Autowired
    private StorageAreaMapper storageAreaMapper;

    /**
     * 查询库位设置
     * 
     * @param areaId 库位设置主键
     * @return 库位设置
     */
    @Override
    public StorageArea selectStorageAreaByAreaId(Long areaId)
    {
        return storageAreaMapper.selectStorageAreaByAreaId(areaId);
    }

    /**
     * 查询库位设置列表
     * 
     * @param storageArea 库位设置
     * @return 库位设置
     */
    @Override
    public List<StorageArea> selectStorageAreaList(StorageArea storageArea)
    {
        return storageAreaMapper.selectStorageAreaList(storageArea);
    }

    /**
     * 新增库位设置
     * 
     * @param storageArea 库位设置
     * @return 结果
     */
    @Override
    public int insertStorageArea(StorageArea storageArea)
    {
        storageArea.setCreateTime(DateUtils.getNowDate());
        return storageAreaMapper.insertStorageArea(storageArea);
    }

    /**
     * 修改库位设置
     * 
     * @param storageArea 库位设置
     * @return 结果
     */
    @Override
    public int updateStorageArea(StorageArea storageArea)
    {
        storageArea.setUpdateTime(DateUtils.getNowDate());
        return storageAreaMapper.updateStorageArea(storageArea);
    }

    /**
     * 批量删除库位设置
     * 
     * @param areaIds 需要删除的库位设置主键
     * @return 结果
     */
    @Override
    public int deleteStorageAreaByAreaIds(Long[] areaIds)
    {
        return storageAreaMapper.deleteStorageAreaByAreaIds(areaIds);
    }

    /**
     * 删除库位设置信息
     * 
     * @param areaId 库位设置主键
     * @return 结果
     */
    @Override
    public int deleteStorageAreaByAreaId(Long areaId)
    {
        return storageAreaMapper.deleteStorageAreaByAreaId(areaId);
    }

    //修改库区是否启用
    public boolean updateStorageAreaIsEnable(StorageArea storageArea)
    {
        return storageAreaMapper.updateStorageareaIsEnable(storageArea);
    }

}
